/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package advanced_class_design.use_enumerated_types;

/**
 *
 * @author arifnasution
 */
public class SampleEnum2
{

    public enum MathOperation
    {

        plus, minus, divide, times;

        double apply( double x, double y )
        {
            double temp = 0;
            switch ( this )
            {
                case plus:
                    temp = x + y;
                    break;
                case minus:
                    temp = x - y;
                    break;
                case divide:
                    temp = x / y;
                    break;
                case times:
                    temp = x * y;
                    break;
            }
            return temp;
        }
    }

    public static void main( String args[] )
    {
        MathOperation mathOperation = MathOperation.plus;
        System.out.println( "result of apply (10, 15) " + mathOperation.apply( 10, 15 ) );
    }
}
